import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '编号',
    align:"center",
    dataIndex: 'bh'
   },
   {
    title: '出租地址',
    align:"center",
    dataIndex: 'czdz'
   },
   {
    title: '总面积',
    align:"center",
    dataIndex: 'area'
   },
   {
    title: '承租方',
    align:"center",
    dataIndex: 'czf'
   },
   {
    title: '法人代表',
    align:"center",
    dataIndex: 'frdb'
   },
   {
    title: '联系电话',
    align:"center",
    dataIndex: 'ftel'
   },
   {
    title: '出租方',
    align:"center",
    dataIndex: 'lessa'
   },
   {
    title: '联系电话',
    align:"center",
    dataIndex: 'ltel'
   },
   {
    title: '经营范围',
    align:"center",
    dataIndex: 'jyfw'
   },
   {
    title: '商铺面积',
    align:"center",
    dataIndex: 'spmj'
   },
   {
    title: '签订日期',
    align:"center",
    dataIndex: 'qdrq',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '租金',
    align:"center",
    dataIndex: 'rent'
   },
   {
    title: '承租年限',
    align:"center",
    dataIndex: 'cznx'
   },
   {
    title: '保证金',
    align:"center",
    dataIndex: 'bail'
   },
   {
    title: '计费起始日期',
    align:"center",
    dataIndex: 'ksrq',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '结止日期',
    align:"center",
    dataIndex: 'zzrq',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '合同文件',
    align:"center",
    dataIndex: 'flname',
    slots: { customRender: 'flnameSlot' },
   },
   {
    title: '状态',
    align:"center",
    dataIndex: 'state',
     customRender:({text})=>{
       return text=='0'?'正常':text=='1'?'作废':text;
     },
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'bz'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "承租方",
      field: 'czf',
      component: 'JInput',
      colProps: {span: 6},
 	},
	{
      label: "出租方",
      field: 'lessa',
      component: 'JSearchSelect',
      colProps: {span: 6},
      componentProps:{
        dict:"DB_CZFB,MC,MC",
        async:true,
        pageSize:10,
      }
 	},
     {
      label: "签订日期",
      field: "qdrq",
      component: 'RangePicker',
      componentProps: {
          valueType: 'Date',
      },
      colProps: {span: 6},
	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'bh',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入编号!'},
          ];
     },
  },
  {
    label: '出租地址',
    field: 'czdz',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入出租地址!'},
          ];
     },
  },
  {
    label: '总面积',
    field: 'area',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入总面积!'},
          ];
     },
  },
  {
    label: '承租方',
    field: 'czf',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入承租方!'},
          ];
     },
  },
  {
    label: '法人代表',
    field: 'frdb',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入法人代表!'},
          ];
     },
  },
  {
    label: '联系电话',
    field: 'ftel',
    component: 'Input',
  },
  {
    label: '出租方',
    field: 'lessa',
    component: 'JSearchSelect',
    componentProps:{
      dict:"DB_CZFB,MC,MC",
      async:true,
      pageSize:10,
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入出租方!'},
          ];
     },
  },
  {
    label: '联系电话',
    field: 'ltel',
    component: 'Input',
  },
  {
    label: '经营范围',
    field: 'jyfw',
    component: 'Input',
  },
  {
    label: '商铺面积',
    field: 'spmj',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入商铺面积!'},
          ];
     },
  },
  {
    label: '签订日期',
    field: 'qdrq',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入签订日期!'},
          ];
     },
  },
  {
    label: '租金',
    field: 'rent',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入租金!'},
          ];
     },
  },
  {
    label: '承租年限',
    field: 'cznx',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入承租年限!'},
          ];
     },
  },
  {
    label: '保证金',
    field: 'bail',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入保证金!'},
          ];
     },
  },
  {
    label: '计费起始日期',
    field: 'ksrq',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入计费起始日期!'},
          ];
     },
  },
  {
    label: '结止日期',
    field: 'zzrq',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入结止日期!'},
          ];
     },
  },
  {
    label: '合同文件',
    field: 'flname',
    component: 'JUpload',
    helpMessage: '最多上传5个文件',
    componentProps: {
      maxCount: 5,
      bizPath: 'lend'
    },
  },
  {
    label: '状态',
    field: 'state',
    component: 'Select',
    componentProps:{
      options:[{label:'正常',value:'0'},{label:'作废',value:'1'}]
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入状态!'},
          ];
     },
  },
  {
    label: '备注',
    field: 'bz',
    component: 'InputTextArea',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
